using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Tilemaps;
using UnityEngine.UI;

public class UIManager : MonoBehaviour
{
    public Button btn_sliderBar;
    public Button btn_freeCoin;
    public Text text_coin;

    // Start is called before the first frame update
    void Start()
    {
        int coin = PlayerPrefs.GetInt("Tokens", 0);
        this.text_coin.text = coin.ToString();

        this.btn_sliderBar?.onClick.AddListener(() =>
        {
            AdSliderBar.Show(() =>
            {
                this.AddCoin(1);
            }, true);
        
        });

        this.btn_freeCoin?.onClick.AddListener(() =>
        {
            AdConfirm.Show(() =>
            {
                this.AddCoin(1);
            }, true); 
        });
    }

    void AddCoin(int amount = 1)
    {
        int coin = PlayerPrefs.GetInt("Tokens", 0);
        coin += amount;
        PlayerPrefs.SetInt("Tokens", coin);
        this.text_coin.text = coin.ToString();
    }
}
